<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>element</title>
</head>
<body>
<a>点</a>
<input type="button" id="btn" value="设置">
<input type="button" id="btn1" value="删除">
<script>

    var ele_btn = document.getElementById("btn");
    ele_btn.onclick = function () {
        var element_a = document.getElementsByTagName("a")[0];
        element_a.setAttribute("href","http://www.baidu.com")
    }
    var ele_btn1 = document.getElementById("btn1");
    ele_btn1.onclick = function () {
        var element_a = document.getElementsByTagName("a")[0];
        element_a.removeAttribute("href")
    }

</script>
</body>
</html>